<template>
  <h1>用户列表</h1>
  <div> 
    <el-button type="primary" :icon="Edit" circle />
  </div>
  <el-scrollbar>
    <el-table :data="item">
      <el-table-column prop="date" label="Date" width="140" />
      <el-table-column prop="name" label="Name" width="120" />
      <el-table-column prop="address" label="Address" />
      <el-table-column><router-link to="/user/FormTemplate">表单</router-link></el-table-column>
    </el-table>
  </el-scrollbar>
</template>
<script>
import { params } from '../../../public/static/mock/params'

export default {
  name: "UserList",
  data(){
    return{
      item :[]
    }
  },
  //进入路由之前
  beforeRouteEnter:(to,from,next)=>{
    console.log('在进入路由前执行');
      next(vm=>{
        vm.getData(vm);//进入路由之前执行getData()
      });
  },
  //进入路由之后
  beforeRouteLeave:(to,from,next)=>{
    console.log('在离开路由前执行');
      next();
  },
  methods:{
    getData :function (vm){
      this.axios({
        method:'post',
        url:params.localhost_url+'/blog/emploee/getEmploees',
        //url:'http://127.0.0.1:8080/blog/emploee/getEmploees',
        //url:'static/mock/data.json'
        data:{data1:"true"}
      }).then(function (response){
          console.log(response);
          console.log(vm.item);
          vm.item=response.data.item;
      }).catch(function (error) {
          console.log(error);
      });
    }
  }
}
</script>
<style scoped>
</style>
